package ml.tewas.commondata;

import java.util.HashMap;
import java.util.Map;


public class ThreatEvaluationResultStruct {

	Map<ForceEnum, ThreatClassificationEnum> otherAgentClassifications = new HashMap<ForceEnum, ThreatClassificationEnum>();

	ThreatClassificationEnum agentOwnClassification;

	public ThreatClassificationEnum getAgentOwnClassification() {
		return agentOwnClassification;
	}

	public void setAgentOwnClassification(
			ThreatClassificationEnum agentOwnClassification) {
		this.agentOwnClassification = agentOwnClassification;
	}

	public ThreatClassificationEnum getOtherAgentClassification(
			ForceEnum agentType) {
		return otherAgentClassifications.get(agentType);
	}

	public void putOtherAgentClassifications(ForceEnum agentType,
			ThreatClassificationEnum otherAgentClassification) {
		this.otherAgentClassifications.put(agentType, otherAgentClassification);
	}

	@Override
	public boolean equals(Object obj) {

		ThreatEvaluationResultStruct state = (ThreatEvaluationResultStruct) obj;
		for (ForceEnum agentType : ForceEnum.values()) {
			if (this.getOtherAgentClassification(agentType) != state
					.getOtherAgentClassification(agentType)) {
				return false;
			}
		}
		return state.getAgentOwnClassification() == this.agentOwnClassification;
	}
	
	@Override
	public int hashCode() {

		int otherAgentsHash = 0;
		int constant = 10;
		for (ForceEnum agentType : ForceEnum.values()) {
			otherAgentsHash += constant
					* this.getOtherAgentClassification(agentType).ordinal();
			constant *= constant;
		}

		return this.agentOwnClassification.ordinal() + otherAgentsHash;
	}
}
